<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/* jws-3.3.12 (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
<span class='line'>  2</span>  */</span><span class="WHIT">
<span class='line'>  3</span> </span><span class="COMM">/*
<span class='line'>  4</span>  * jws.js - JSON Web Signature(JWS) and JSON Web Token(JWT) Class
<span class='line'>  5</span>  *
<span class='line'>  6</span>  * Copyright (c) 2010-2022 Kenji Urushima (kenji.urushima@gmail.com)
<span class='line'>  7</span>  *
<span class='line'>  8</span>  * This software is licensed under the terms of the MIT License.
<span class='line'>  9</span>  * https://kjur.github.io/jsrsasign/license/
<span class='line'> 10</span>  *
<span class='line'> 11</span>  * The above copyright and license notice shall be 
<span class='line'> 12</span>  * included in all copies or substantial portions of the Software.
<span class='line'> 13</span>  */</span><span class="WHIT">
<span class='line'> 14</span> 
<span class='line'> 15</span> </span><span class="COMM">/**
<span class='line'> 16</span>  * @fileOverview
<span class='line'> 17</span>  * @name jws-3.3.js
<span class='line'> 18</span>  * @author Kenji Urushima kenji.urushima@gmail.com
<span class='line'> 19</span>  * @version jsrsasign 10.5.25 jws 3.3.12 (2022-Jun-23)
<span class='line'> 20</span>  * @since jsjws 1.0, jsrsasign 4.8.0
<span class='line'> 21</span>  * @license &lt;a href="https://kjur.github.io/jsrsasign/license/">MIT License&lt;/a>
<span class='line'> 22</span>  */</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 25</span> 
<span class='line'> 26</span> </span><span class="COMM">/**
<span class='line'> 27</span>  * kjur's JSON Web Signature/Token(JWS/JWT) library name space
<span class='line'> 28</span>  * &lt;p>
<span class='line'> 29</span>  * This namespace privides following JWS/JWS related classes.
<span class='line'> 30</span>  * &lt;ul>
<span class='line'> 31</span>  * &lt;li>{@link KJUR.jws.JWS} - JSON Web Signature/Token(JWS/JWT) class&lt;/li>
<span class='line'> 32</span>  * &lt;li>{@link KJUR.jws.JWSJS} - JWS JSON Serialization(JWSJS) class&lt;/li>
<span class='line'> 33</span>  * &lt;li>{@link KJUR.jws.IntDate} - UNIX origin time utility class&lt;/li>
<span class='line'> 34</span>  * &lt;/ul>
<span class='line'> 35</span>  * NOTE: Please ignore method summary and document of this namespace. This caused by a bug of jsdoc2.
<span class='line'> 36</span>  * &lt;/p>
<span class='line'> 37</span>  * @name KJUR.jws
<span class='line'> 38</span>  * @namespace
<span class='line'> 39</span>  */</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">KJUR.jws</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">KJUR.jws</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">KJUR.jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 41</span> 
<span class='line'> 42</span> </span><span class="COMM">/**
<span class='line'> 43</span>  * JSON Web Signature(JWS) class.&lt;br/>
<span class='line'> 44</span>  * @name KJUR.jws.JWS
<span class='line'> 45</span>  * @class JSON Web Signature(JWS) class
<span class='line'> 46</span>  * @see &lt;a href="https://kjur.github.io/jsjws/">'jwjws'(JWS JavaScript Library) home page https://kjur.github.io/jsjws/&lt;/a>
<span class='line'> 47</span>  * @see &lt;a href="https://kjur.github.io/jsrsasigns/">'jwrsasign'(RSA Sign JavaScript Library) home page https://kjur.github.io/jsrsasign/&lt;/a>
<span class='line'> 48</span>  * @see &lt;a href="http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-14">IETF I-D JSON Web Algorithms (JWA)&lt;/a>
<span class='line'> 49</span>  * @since jsjws 1.0
<span class='line'> 50</span>  * @description
<span class='line'> 51</span>  * This class provides JSON Web Signature(JWS)/JSON Web Token(JWT) signing and validation.
<span class='line'> 52</span>  *
<span class='line'> 53</span>  * &lt;h4>METHOD SUMMARY&lt;/h4>
<span class='line'> 54</span>  * Here is major methods of {@link KJUR.jws.JWS} class.
<span class='line'> 55</span>  * &lt;ul>
<span class='line'> 56</span>  * &lt;li>&lt;b>SIGN&lt;/b>&lt;br/>
<span class='line'> 57</span>  * &lt;li>{@link KJUR.jws.JWS.sign} - sign JWS&lt;/li>
<span class='line'> 58</span>  * &lt;/li>
<span class='line'> 59</span>  * &lt;li>&lt;b>VERIFY&lt;/b>&lt;br/>
<span class='line'> 60</span>  * &lt;li>{@link KJUR.jws.JWS.verify} - verify JWS signature&lt;/li>
<span class='line'> 61</span>  * &lt;li>{@link KJUR.jws.JWS.verifyJWT} - verify properties of JWT token at specified time&lt;/li>
<span class='line'> 62</span>  * &lt;/li>
<span class='line'> 63</span>  * &lt;li>&lt;b>UTILITY&lt;/b>&lt;br/>
<span class='line'> 64</span>  * &lt;li>{@link KJUR.jws.JWS.getJWKthumbprint} - get RFC 7638 JWK thumbprint&lt;/li>
<span class='line'> 65</span>  * &lt;li>{@link KJUR.jws.JWS.isSafeJSONString} - check whether safe JSON string or not&lt;/li>
<span class='line'> 66</span>  * &lt;li>{@link KJUR.jws.JWS.readSafeJSONString} - read safe JSON string only&lt;/li>
<span class='line'> 67</span>  * &lt;/li>
<span class='line'> 68</span>  * &lt;/ul> 
<span class='line'> 69</span>  *
<span class='line'> 70</span>  * &lt;h4>SUPPORTED SIGNATURE ALGORITHMS&lt;/h4>
<span class='line'> 71</span>  * Here is supported algorithm names for {@link KJUR.jws.JWS.sign} and
<span class='line'> 72</span>  * {@link KJUR.jws.JWS.verify} methods.
<span class='line'> 73</span>  * &lt;table>
<span class='line'> 74</span>  * &lt;tr>&lt;th>alg value&lt;/th>&lt;th>spec requirement&lt;/th>&lt;th>jsjws support&lt;/th>&lt;/tr>
<span class='line'> 75</span>  * &lt;tr>&lt;td>HS256&lt;/td>&lt;td>REQUIRED&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 76</span>  * &lt;tr>&lt;td>HS384&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 77</span>  * &lt;tr>&lt;td>HS512&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 78</span>  * &lt;tr>&lt;td>RS256&lt;/td>&lt;td>RECOMMENDED&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 79</span>  * &lt;tr>&lt;td>RS384&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 80</span>  * &lt;tr>&lt;td>RS512&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 81</span>  * &lt;tr>&lt;td>ES256&lt;/td>&lt;td>RECOMMENDED+&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 82</span>  * &lt;tr>&lt;td>ES384&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 83</span>  * &lt;tr>&lt;td>ES512&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>-&lt;/td>&lt;/tr>
<span class='line'> 84</span>  * &lt;tr>&lt;td>PS256&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 85</span>  * &lt;tr>&lt;td>PS384&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 86</span>  * &lt;tr>&lt;td>PS512&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'> 87</span>  * &lt;tr>&lt;td>none&lt;/td>&lt;td>REQUIRED&lt;/td>&lt;td>SUPPORTED(signature generation only)&lt;/td>&lt;/tr>
<span class='line'> 88</span>  * &lt;/table>
<span class='line'> 89</span>  * &lt;dl>
<span class='line'> 90</span>  * &lt;dt>&lt;b>NOTE1&lt;/b>
<span class='line'> 91</span>  * &lt;dd>HS384 is supported since jsjws 3.0.2 with jsrsasign 4.1.4.
<span class='line'> 92</span>  * &lt;dt>&lt;b>NOTE2&lt;/b>
<span class='line'> 93</span>  * &lt;dd>Some deprecated methods have been removed since jws 3.3 of jsrsasign 4.10.0.
<span class='line'> 94</span>  * Removed methods are following:
<span class='line'> 95</span>  * &lt;ul>
<span class='line'> 96</span>  * &lt;li>JWS.verifyJWSByNE&lt;/li>
<span class='line'> 97</span>  * &lt;li>JWS.verifyJWSByKey&lt;/li>
<span class='line'> 98</span>  * &lt;li>JWS.generateJWSByNED&lt;/li>
<span class='line'> 99</span>  * &lt;li>JWS.generateJWSByKey&lt;/li>
<span class='line'>100</span>  * &lt;li>JWS.generateJWSByP1PrvKey&lt;/li>
<span class='line'>101</span>  * &lt;/ul>
<span class='line'>102</span>  * &lt;/dl>
<span class='line'>103</span>  * &lt;b>EXAMPLE&lt;/b>&lt;br/>
<span class='line'>104</span>  * @example
<span class='line'>105</span>  * // JWS signing 
<span class='line'>106</span>  * sJWS = KJUR.jws.JWS.sign(null, '{"alg":"HS256", "cty":"JWT"}', '{"age": 21}', {"utf8": "password"});
<span class='line'>107</span>  * // JWS validation
<span class='line'>108</span>  * isValid = KJUR.jws.JWS.verify('eyJjdHkiOiJKV1QiLCJhbGc...', {"utf8": "password"});
<span class='line'>109</span>  * // JWT validation
<span class='line'>110</span>  * isValid = KJUR.jws.JWS.verifyJWT('eyJh...', {"utf8": "password"}, {
<span class='line'>111</span>  *   alg: ['HS256', 'HS384'],
<span class='line'>112</span>  *   iss: ['http://foo.com']
<span class='line'>113</span>  * });
<span class='line'>114</span>  */</span><span class="WHIT">
<span class='line'>115</span> </span><span class="NAME">KJUR.jws.JWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_jws_JWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR.jws.JWS</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">	</span><span class="NAME">_isSafeJSONString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.isSafeJSONString</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>119</span> 
<span class='line'>120</span> </span><span class="WHIT">    </span><span class="COMM">// === utility =============================================================</span><span class="WHIT">
<span class='line'>121</span> 
<span class='line'>122</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>123</span>      * parse JWS string and set public property 'parsedJWS' dictionary.&lt;br/>
<span class='line'>124</span>      * @name parseJWS
<span class='line'>125</span>      * @memberOf KJUR.jws.JWS
<span class='line'>126</span>      * @function
<span class='line'>127</span>      * @param {String} sJWS JWS signature string to be parsed.
<span class='line'>128</span>      * @throws if sJWS is not comma separated string such like "Header.Payload.Signature".
<span class='line'>129</span>      * @throws if JWS Header is a malformed JSON string.
<span class='line'>130</span>      * @since jws 1.1
<span class='line'>131</span>      */</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">    </span><span class="NAME">this.parseJWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sJWS</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sigValNotNeeded</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">this.parsedJWS</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">	    </span><span class="PUNC">(</span><span class="NAME">sigValNotNeeded</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.parsedJWS.sigvalH</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">matchResult</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sJWS.match</span><span class="PUNC">(</span><span class="REGX">/^([^.]+)\.([^.]+)\.([^.]+)$/</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"JWS signature is not a form of 'Head.Payload.SigValue'."</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b6Head</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b6Payload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">b6SigVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">3</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sSI</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b6Head</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">b6Payload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">	</span><span class="NAME">this.parsedJWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">	</span><span class="NAME">this.parsedJWS.headB64U</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b6Head</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">	</span><span class="NAME">this.parsedJWS.payloadB64U</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b6Payload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">	</span><span class="NAME">this.parsedJWS.sigvalB64U</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b6SigVal</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">	</span><span class="NAME">this.parsedJWS.si</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sSI</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>150</span> 
<span class='line'>151</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">sigValNotNeeded</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hSigVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">b6SigVal</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">biSigVal</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">parseBigInt</span><span class="PUNC">(</span><span class="NAME">hSigVal</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">16</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">	    </span><span class="NAME">this.parsedJWS.sigvalH</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hSigVal</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">	    </span><span class="NAME">this.parsedJWS.sigvalBI</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">biSigVal</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>157</span> 
<span class='line'>158</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sHead</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">b6Head</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">b6Payload</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">	</span><span class="NAME">this.parsedJWS.headS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sHead</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">	</span><span class="NAME">this.parsedJWS.payloadS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sPayload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>162</span> 
<span class='line'>163</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_isSafeJSONString</span><span class="PUNC">(</span><span class="NAME">sHead</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.parsedJWS</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'headP'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"malformed JSON string for JWS Head: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sHead</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>166</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> 
<span class='line'>168</span> </span><span class="COMM">// === major static method ========================================================</span><span class="WHIT">
<span class='line'>169</span> 
<span class='line'>170</span> </span><span class="COMM">/**
<span class='line'>171</span>  * generate JWS signature by specified key&lt;br/>
<span class='line'>172</span>  * @name sign
<span class='line'>173</span>  * @memberOf KJUR.jws.JWS
<span class='line'>174</span>  * @function
<span class='line'>175</span>  * @static
<span class='line'>176</span>  * @param {String} alg JWS algorithm name to sign and force set to sHead or null 
<span class='line'>177</span>  * @param {String} spHead string or object of JWS Header
<span class='line'>178</span>  * @param {String} spPayload string or object of JWS Payload
<span class='line'>179</span>  * @param {String} key string of private key or mac key object to sign
<span class='line'>180</span>  * @param {String} pass (OPTION)passcode to use encrypted asymmetric private key 
<span class='line'>181</span>  * @return {String} JWS signature string
<span class='line'>182</span>  * @since jws 3.0.0
<span class='line'>183</span>  * @see &lt;a href="https://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.Signature.html">jsrsasign KJUR.crypto.Signature method&lt;/a>
<span class='line'>184</span>  * @see &lt;a href="https://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.Mac.html">jsrsasign KJUR.crypto.Mac method&lt;/a>
<span class='line'>185</span>  * @description
<span class='line'>186</span>  * This method supports following algorithms.
<span class='line'>187</span>  * &lt;table>
<span class='line'>188</span>  * &lt;tr>&lt;th>alg value&lt;/th>&lt;th>spec requirement&lt;/th>&lt;th>jsjws support&lt;/th>&lt;/tr>
<span class='line'>189</span>  * &lt;tr>&lt;td>HS256&lt;/td>&lt;td>REQUIRED&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>190</span>  * &lt;tr>&lt;td>HS384&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>191</span>  * &lt;tr>&lt;td>HS512&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>192</span>  * &lt;tr>&lt;td>RS256&lt;/td>&lt;td>RECOMMENDED&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>193</span>  * &lt;tr>&lt;td>RS384&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>194</span>  * &lt;tr>&lt;td>RS512&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>195</span>  * &lt;tr>&lt;td>ES256&lt;/td>&lt;td>RECOMMENDED+&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>196</span>  * &lt;tr>&lt;td>ES384&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>197</span>  * &lt;tr>&lt;td>ES512&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>-&lt;/td>&lt;/tr>
<span class='line'>198</span>  * &lt;tr>&lt;td>PS256&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>199</span>  * &lt;tr>&lt;td>PS384&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>200</span>  * &lt;tr>&lt;td>PS512&lt;/td>&lt;td>OPTIONAL&lt;/td>&lt;td>SUPPORTED&lt;/td>&lt;/tr>
<span class='line'>201</span>  * &lt;tr>&lt;td>none&lt;/td>&lt;td>REQUIRED&lt;/td>&lt;td>SUPPORTED(signature generation only)&lt;/td>&lt;/tr>
<span class='line'>202</span>  * &lt;/table>
<span class='line'>203</span>  * &lt;dl>
<span class='line'>204</span>  * &lt;dt>NOTE1:
<span class='line'>205</span>  * &lt;dd>salt length of RSAPSS signature is the same as the hash algorithm length
<span class='line'>206</span>  * because of &lt;a href="http://www.ietf.org/mail-archive/web/jose/current/msg02901.html">IETF JOSE ML discussion&lt;/a>.
<span class='line'>207</span>  * &lt;dt>NOTE2:
<span class='line'>208</span>  * &lt;dd>To support HS384, patched version of CryptoJS is used.
<span class='line'>209</span>  * &lt;a href="https://code.google.com/p/crypto-js/issues/detail?id=84">See here for detail&lt;/a>.
<span class='line'>210</span>  * &lt;dt>NOTE3:
<span class='line'>211</span>  * From jsrsasign 4.10.0 jws 3.3.0, Way to provide password
<span class='line'>212</span>  * for HS* algorithm is changed. The 'key' attribute value is
<span class='line'>213</span>  * passed to {@link KJUR.crypto.Mac.setPassword} so please see
<span class='line'>214</span>  * {@link KJUR.crypto.Mac.setPassword} for detail.
<span class='line'>215</span>  * As for backword compatibility, if key is a string, has even length and
<span class='line'>216</span>  * 0..9, A-F or a-f characters, key string is treated as a hexadecimal
<span class='line'>217</span>  * otherwise it is treated as a raw string.
<span class='line'>218</span>  * &lt;dd>
<span class='line'>219</span>  * &lt;/dl>
<span class='line'>220</span>  * &lt;b>EXAMPLE&lt;/b>&lt;br/>
<span class='line'>221</span>  * @example
<span class='line'>222</span>  * // sign HS256 signature with password "aaa" implicitly handled as string
<span class='line'>223</span>  * sJWS = KJUR.jws.JWS.sign(null, {alg: "HS256", cty: "JWT"}, {age: 21}, "aaa");
<span class='line'>224</span>  * // sign HS256 signature with password "6161" implicitly handled as hex
<span class='line'>225</span>  * sJWS = KJUR.jws.JWS.sign(null, {alg: "HS256", cty: "JWT"}, {age: 21}, "6161");
<span class='line'>226</span>  * // sign HS256 signature with base64 password
<span class='line'>227</span>  * sJWS = KJUR.jws.JWS.sign(null, {alg: "HS256"}, {age: 21}, {b64: "Mi/8..a="});
<span class='line'>228</span>  * // sign RS256 signature with PKCS#8 PEM RSA private key
<span class='line'>229</span>  * sJWS = KJUR.jws.JWS.sign(null, {alg: "RS256"}, {age: 21}, "-----BEGIN PRIVATE KEY...");
<span class='line'>230</span>  * // sign RS256 signature with PKCS#8 PEM ECC private key with passcode
<span class='line'>231</span>  * sJWS = KJUR.jws.JWS.sign(null, {alg: "ES256"}, {age: 21}, 
<span class='line'>232</span>  *                          "-----BEGIN PRIVATE KEY...", "keypass");
<span class='line'>233</span>  * // header and payload can be passed by both string and object
<span class='line'>234</span>  * sJWS = KJUR.jws.JWS.sign(null, '{alg:"HS256",cty:"JWT"}', '{age:21}', "aaa");
<span class='line'>235</span>  */</span><span class="WHIT">
<span class='line'>236</span> </span><span class="NAME">KJUR.jws.JWS.sign</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">spHeader</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">spPayload</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR.jws</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_jws_JWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws.JWS</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">	</span><span class="NAME">_readSafeJSONString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.readSafeJSONString</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>241</span> </span><span class="WHIT">	</span><span class="NAME">_isSafeJSONString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.isSafeJSONString</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>242</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_crypto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR.crypto</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">	</span><span class="NAME">_ECDSA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto.ECDSA</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>244</span> </span><span class="WHIT">	</span><span class="NAME">_Mac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto.Mac</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>245</span> </span><span class="WHIT">	</span><span class="NAME">_Signature</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto.Signature</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">	</span><span class="NAME">_JSON</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">JSON</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>247</span> 
<span class='line'>248</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sHeader</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pHeader</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sPayload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>249</span> 
<span class='line'>250</span> </span><span class="WHIT">    </span><span class="COMM">// 1. check signatureInput(Header, Payload) is string or object</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">spHeader</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">spHeader</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"spHeader must be JSON string or object: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">spHeader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>253</span> 
<span class='line'>254</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">spHeader</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">	</span><span class="NAME">pHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">spHeader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">	</span><span class="NAME">sHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_JSON.stringify</span><span class="PUNC">(</span><span class="NAME">pHeader</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>258</span> 
<span class='line'>259</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">spHeader</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">	</span><span class="NAME">sHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">spHeader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_isSafeJSONString</span><span class="PUNC">(</span><span class="NAME">sHeader</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"JWS Head is not safe JSON string: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sHeader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>263</span> </span><span class="WHIT">	</span><span class="NAME">pHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_readSafeJSONString</span><span class="PUNC">(</span><span class="NAME">sHeader</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>264</span> 
<span class='line'>265</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>266</span> 
<span class='line'>267</span> </span><span class="WHIT">    </span><span class="NAME">sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">spPayload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">spPayload</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">sPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_JSON.stringify</span><span class="PUNC">(</span><span class="NAME">spPayload</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>269</span> 
<span class='line'>270</span> </span><span class="WHIT">    </span><span class="COMM">// 2. use alg if defined in sHeader</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">	</span><span class="NAME">pHeader</span><span class="PUNC">[</span><span class="STRN">'alg'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">	</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pHeader</span><span class="PUNC">[</span><span class="STRN">'alg'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>275</span> 
<span class='line'>276</span> </span><span class="WHIT">    </span><span class="COMM">// 3. update sHeader to add alg if alg undefined</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">	</span><span class="NAME">pHeader</span><span class="PUNC">[</span><span class="STRN">'alg'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">	</span><span class="NAME">pHeader</span><span class="PUNC">[</span><span class="STRN">'alg'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">	</span><span class="NAME">sHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_JSON.stringify</span><span class="PUNC">(</span><span class="NAME">pHeader</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>282</span> 
<span class='line'>283</span> </span><span class="WHIT">    </span><span class="COMM">// 4. check explicit algorithm doesn't match with JWS header.</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">pHeader.alg</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"alg and sHeader.alg doesn't match: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"!="</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pHeader.alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>286</span> 
<span class='line'>287</span> </span><span class="WHIT">    </span><span class="COMM">// 5. set signature algorithm like SHA1withRSA</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sigAlg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_KJUR_jws_JWS.jwsalg2sigalg</span><span class="PUNC">[</span><span class="NAME">alg</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"unsupported alg name: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">	</span><span class="NAME">sigAlg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.jwsalg2sigalg</span><span class="PUNC">[</span><span class="NAME">alg</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">    
<span class='line'>295</span>     </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">utf8tob64u</span><span class="PUNC">(</span><span class="NAME">sHeader</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">utf8tob64u</span><span class="PUNC">(</span><span class="NAME">sPayload</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uSignatureInput</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">uHeader</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">uPayload</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">    </span><span class="COMM">// 6. sign</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigAlg.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"Hmac"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"mac key shall be specified for HS* alg"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">	</span><span class="COMM">//alert("sigAlg=" + sigAlg);</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Mac</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sigAlg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'prov'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'cryptojs'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'pass'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">	</span><span class="NAME">mac.updateString</span><span class="PUNC">(</span><span class="NAME">uSignatureInput</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">	</span><span class="NAME">hSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mac.doFinal</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigAlg.indexOf</span><span class="PUNC">(</span><span class="STRN">"withECDSA"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Signature</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sigAlg</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">	</span><span class="NAME">sig.init</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">	</span><span class="NAME">sig.updateString</span><span class="PUNC">(</span><span class="NAME">uSignatureInput</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hASN1Sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sig.sign</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">	</span><span class="NAME">hSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.ECDSA.asn1SigToConcatSig</span><span class="PUNC">(</span><span class="NAME">hASN1Sig</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigAlg</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"none"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Signature</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sigAlg</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">	</span><span class="NAME">sig.init</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pass</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">	</span><span class="NAME">sig.updateString</span><span class="PUNC">(</span><span class="NAME">uSignatureInput</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT">	</span><span class="NAME">hSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sig.sign</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>319</span> 
<span class='line'>320</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hextob64u</span><span class="PUNC">(</span><span class="NAME">hSig</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">uSignatureInput</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">uSig</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>322</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>323</span> 
<span class='line'>324</span> </span><span class="COMM">/**
<span class='line'>325</span>  * verify JWS signature by specified key or certificate&lt;br/>
<span class='line'>326</span>  * @name verify
<span class='line'>327</span>  * @memberOf KJUR.jws.JWS
<span class='line'>328</span>  * @function
<span class='line'>329</span>  * @static
<span class='line'>330</span>  * @param {String} sJWS string of JWS signature to verify
<span class='line'>331</span>  * @param {Object} key string of public key, certificate or key object to verify
<span class='line'>332</span>  * @param {String} acceptAlgs array of algorithm name strings (OPTION)
<span class='line'>333</span>  * @return {Boolean} true if the signature is valid otherwise false including no signature case or without head and payload
<span class='line'>334</span>  * @since jws 3.0.0
<span class='line'>335</span>  * @see &lt;a href="https://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.Signature.html">jsrsasign KJUR.crypto.Signature method&lt;/a>
<span class='line'>336</span>  * @see &lt;a href="https://kjur.github.io/jsrsasign/api/symbols/KJUR.crypto.Mac.html">jsrsasign KJUR.crypto.Mac method&lt;/a>
<span class='line'>337</span>  * @description
<span class='line'>338</span>  * &lt;p>
<span class='line'>339</span>  * This method verifies a JSON Web Signature Compact Serialization string by the validation 
<span class='line'>340</span>  * algorithm as described in 
<span class='line'>341</span>  * &lt;a href="http://self-issued.info/docs/draft-jones-json-web-signature-04.html#anchor5">
<span class='line'>342</span>  * the section 5 of Internet Draft draft-jones-json-web-signature-04.&lt;/a>
<span class='line'>343</span>  * &lt;/p>
<span class='line'>344</span>  * &lt;p>
<span class='line'>345</span>  * Since 3.2.0 strict key checking has been provided against a JWS algorithm
<span class='line'>346</span>  * in a JWS header.
<span class='line'>347</span>  * &lt;ul>
<span class='line'>348</span>  * &lt;li>In case 'alg' is 'HS*' in the JWS header,
<span class='line'>349</span>  * 'key' shall be hexadecimal string for Hmac{256,384,512} shared secret key.
<span class='line'>350</span>  * Otherwise it raise an error.&lt;/li>
<span class='line'>351</span>  * &lt;li>In case 'alg' is 'RS*' or 'PS*' in the JWS header,
<span class='line'>352</span>  * 'key' shall be a RSAKey object or a PEM string of
<span class='line'>353</span>  * X.509 RSA public key certificate or PKCS#8 RSA public key.
<span class='line'>354</span>  * Otherwise it raise an error.&lt;/li>
<span class='line'>355</span>  * &lt;li>In case 'alg' is 'ES*' in the JWS header,
<span class='line'>356</span>  * 'key' shall be a KJUR.crypto.ECDSA object or a PEM string of
<span class='line'>357</span>  * X.509 ECC public key certificate or PKCS#8 ECC public key.
<span class='line'>358</span>  * Otherwise it raise an error.&lt;/li>
<span class='line'>359</span>  * &lt;li>In case 'alg' is 'none' in the JWS header,
<span class='line'>360</span>  * validation not supported after jsjws 3.1.0.&lt;/li>
<span class='line'>361</span>  * &lt;/ul>
<span class='line'>362</span>  * &lt;/p>
<span class='line'>363</span>  * &lt;p>
<span class='line'>364</span>  * NOTE1: The argument 'acceptAlgs' is supported since 3.2.0.
<span class='line'>365</span>  * Strongly recommended to provide acceptAlgs to mitigate
<span class='line'>366</span>  * signature replacement attacks.&lt;br/>
<span class='line'>367</span>  * &lt;/p>
<span class='line'>368</span>  * &lt;p>
<span class='line'>369</span>  * NOTE2: From jsrsasign 4.9.0 jws 3.2.5, Way to provide password
<span class='line'>370</span>  * for HS* algorithm is changed. The 'key' attribute value is
<span class='line'>371</span>  * passed to {@link KJUR.crypto.Mac.setPassword} so please see
<span class='line'>372</span>  * {@link KJUR.crypto.Mac.setPassword} for detail.
<span class='line'>373</span>  * As for backword compatibility, if key is a string, has even length and
<span class='line'>374</span>  * 0..9, A-F or a-f characters, key string is treated as a hexadecimal
<span class='line'>375</span>  * otherwise it is treated as a raw string.
<span class='line'>376</span>  * &lt;/p>
<span class='line'>377</span>  * @example
<span class='line'>378</span>  * // 1) verify a RS256 JWS signature by a certificate string.
<span class='line'>379</span>  * isValid = KJUR.jws.JWS.verify('eyJh...', '-----BEGIN...', ['RS256']);
<span class='line'>380</span>  * 
<span class='line'>381</span>  * // 2) verify a HS256 JWS signature by a certificate string.
<span class='line'>382</span>  * isValid = KJUR.jws.JWS.verify('eyJh...', {hex: '6f62ad...'}, ['HS256']);
<span class='line'>383</span>  * isValid = KJUR.jws.JWS.verify('eyJh...', {b64: 'Mi/ab8...a=='}, ['HS256']);
<span class='line'>384</span>  * isValid = KJUR.jws.JWS.verify('eyJh...', {utf8: 'Secret秘密'}, ['HS256']);
<span class='line'>385</span>  * isValid = KJUR.jws.JWS.verify('eyJh...', '6f62ad', ['HS256']); // implicit hex
<span class='line'>386</span>  * isValid = KJUR.jws.JWS.verify('eyJh...', '6f62ada', ['HS256']); // implicit raw string
<span class='line'>387</span>  *
<span class='line'>388</span>  * // 3) verify a ES256 JWS signature by a KJUR.crypto.ECDSA key object.
<span class='line'>389</span>  * var pubkey = KEYUTIL.getKey('-----BEGIN CERT...');
<span class='line'>390</span>  * var isValid = KJUR.jws.JWS.verify('eyJh...', pubkey);
<span class='line'>391</span>  */</span><span class="WHIT">
<span class='line'>392</span> </span><span class="NAME">KJUR.jws.JWS.verify</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sJWS</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">acceptAlgs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR.jws</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_jws_JWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws.JWS</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">	</span><span class="NAME">_readSafeJSONString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.readSafeJSONString</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_crypto</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR.crypto</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">	</span><span class="NAME">_ECDSA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto.ECDSA</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">	</span><span class="NAME">_Mac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto.Mac</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">	</span><span class="NAME">_Signature</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_crypto.Signature</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">	</span><span class="NAME">_RSAKey</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">    
<span class='line'>403</span>     </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">RSAKey</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">_RSAKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">RSAKey</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>404</span> 
<span class='line'>405</span> </span><span class="WHIT">    </span><span class="COMM">// 0. checking dot concatinatd Base64URL encoded string</span><span class="WHIT">
<span class='line'>406</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">isBase64URLDot</span><span class="PUNC">(</span><span class="NAME">sJWS</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>407</span> 
<span class='line'>408</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sJWS.split</span><span class="PUNC">(</span><span class="STRN">"."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>409</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>410</span> 
<span class='line'>411</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>412</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>413</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uSignatureInput</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">uHeader</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">uPayload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>414</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>415</span> 
<span class='line'>416</span> </span><span class="WHIT">    </span><span class="COMM">// 1. parse JWS header</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_readSafeJSONString</span><span class="PUNC">(</span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">algType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// HS|RS|PS|ES|no</span><span class="WHIT">
<span class='line'>420</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pHeader.alg</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>421</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"algorithm not specified in header"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">	</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pHeader.alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">	</span><span class="NAME">algType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">alg.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>426</span> 
<span class='line'>427</span> </span><span class="WHIT">    </span><span class="COMM">// 2. check whether alg is acceptable algorithms</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">acceptAlgs</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">        </span><span class="NAME">Object.prototype.toString.call</span><span class="PUNC">(</span><span class="NAME">acceptAlgs</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'[object Array]'</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">        </span><span class="NAME">acceptAlgs.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>431</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">acceptAlgStr</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">":"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">acceptAlgs.join</span><span class="PUNC">(</span><span class="STRN">":"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">":"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>432</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">acceptAlgStr.indexOf</span><span class="PUNC">(</span><span class="STRN">":"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">":"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"algorithm '"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"' not accepted in the list"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>435</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>436</span> 
<span class='line'>437</span> </span><span class="WHIT">    </span><span class="COMM">// 3. check whether key is a proper key for alg.</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"none"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>439</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"key shall be specified to verify."</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>440</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>441</span> 
<span class='line'>442</span> </span><span class="WHIT">    </span><span class="COMM">// 3.1. There is no key check for HS* because Mac will check it.</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">    </span><span class="COMM">//      since jsrsasign 5.0.0.</span><span class="WHIT">
<span class='line'>444</span> 
<span class='line'>445</span> </span><span class="WHIT">    </span><span class="COMM">// 3.2. convert key object if key is a public key or cert PEM string</span><span class="WHIT">
<span class='line'>446</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>447</span> </span><span class="WHIT">	</span><span class="NAME">key.indexOf</span><span class="PUNC">(</span><span class="STRN">"-----BEGIN "</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT">	</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KEYUTIL.getKey</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>449</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>450</span> 
<span class='line'>451</span> </span><span class="WHIT">    </span><span class="COMM">// 3.3. check whether key is RSAKey obj if alg is RS* or PS*.</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">algType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"RS"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">algType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"PS"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>453</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">_RSAKey</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"key shall be a RSAKey obj for RS* and PS* algs"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>455</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>457</span> 
<span class='line'>458</span> </span><span class="WHIT">    </span><span class="COMM">// 3.4. check whether key is ECDSA obj if alg is ES*.</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">algType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"ES"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">_ECDSA</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"key shall be a ECDSA obj for ES* algs"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>464</span> 
<span class='line'>465</span> </span><span class="WHIT">    </span><span class="COMM">// 3.5. check when alg is 'none'</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">alg</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"none"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>468</span> 
<span class='line'>469</span> </span><span class="WHIT">    </span><span class="COMM">// 4. check whether alg is supported alg in jsjws.</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sigAlg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>471</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">_KJUR_jws_JWS.jwsalg2sigalg</span><span class="PUNC">[</span><span class="NAME">pHeader.alg</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>472</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"unsupported alg name: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">alg</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT">	</span><span class="NAME">sigAlg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.jwsalg2sigalg</span><span class="PUNC">[</span><span class="NAME">alg</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>475</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>476</span> 
<span class='line'>477</span> </span><span class="WHIT">    </span><span class="COMM">// 5. verify</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigAlg</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"none"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"not supported"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>480</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigAlg.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">4</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"Hmac"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>481</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hSig2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"hexadecimal key shall be specified for HMAC"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT">	</span><span class="COMM">//try {</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT">	    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">mac</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Mac</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sigAlg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'pass'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT">	    </span><span class="NAME">mac.updateString</span><span class="PUNC">(</span><span class="NAME">uSignatureInput</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">	    </span><span class="NAME">hSig2</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">mac.doFinal</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">	</span><span class="COMM">//} catch(ex) {};</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hSig</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">hSig2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sigAlg.indexOf</span><span class="PUNC">(</span><span class="STRN">"withECDSA"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hASN1Sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT">        </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">	    </span><span class="NAME">hASN1Sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_ECDSA.concatSigToASN1Sig</span><span class="PUNC">(</span><span class="NAME">hSig</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>494</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>495</span> </span><span class="WHIT">	    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>496</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>497</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Signature</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sigAlg</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>498</span> </span><span class="WHIT">	</span><span class="NAME">sig.init</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>499</span> </span><span class="WHIT">	</span><span class="NAME">sig.updateString</span><span class="PUNC">(</span><span class="NAME">uSignatureInput</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>500</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sig.verify</span><span class="PUNC">(</span><span class="NAME">hASN1Sig</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">sig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">_Signature</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'alg'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sigAlg</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT">	</span><span class="NAME">sig.init</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT">	</span><span class="NAME">sig.updateString</span><span class="PUNC">(</span><span class="NAME">uSignatureInput</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">sig.verify</span><span class="PUNC">(</span><span class="NAME">hSig</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>507</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>508</span> 
<span class='line'>509</span> </span><span class="COMM">/**
<span class='line'>510</span>  * parse header and payload of JWS signature&lt;br/>
<span class='line'>511</span>  * @name parse
<span class='line'>512</span>  * @memberOf KJUR.jws.JWS
<span class='line'>513</span>  * @function
<span class='line'>514</span>  * @static
<span class='line'>515</span>  * @param {String} sJWS string of JWS signature to parse
<span class='line'>516</span>  * @return {Array} associative array of parsed header and payload. See below.
<span class='line'>517</span>  * @throws if sJWS is malformed JWS signature
<span class='line'>518</span>  * @since jws 3.3.3
<span class='line'>519</span>  * @description
<span class='line'>520</span>  * This method parses JWS signature string. 
<span class='line'>521</span>  * Resulted associative array has following properties:
<span class='line'>522</span>  * &lt;ul>
<span class='line'>523</span>  * &lt;li>headerObj - JSON object of header&lt;/li>
<span class='line'>524</span>  * &lt;li>payloadObj - JSON object of payload if payload is JSON string otherwise undefined&lt;/li>
<span class='line'>525</span>  * &lt;li>headerPP - pretty printed JSON header by stringify&lt;/li>
<span class='line'>526</span>  * &lt;li>payloadPP - pretty printed JSON payload by stringify if payload is JSON otherwise Base64URL decoded raw string of payload&lt;/li>
<span class='line'>527</span>  * &lt;li>sigHex - hexadecimal string of signature&lt;/li>
<span class='line'>528</span>  * &lt;/ul>
<span class='line'>529</span>  * @example
<span class='line'>530</span>  * KJUR.jws.JWS.parse(sJWS) ->
<span class='line'>531</span>  * { 
<span class='line'>532</span>  *   headerObj: {"alg": "RS256", "typ": "JWS"},
<span class='line'>533</span>  *   payloadObj: {"product": "orange", "quantity": 100},
<span class='line'>534</span>  *   headerPP: 
<span class='line'>535</span>  *   '{
<span class='line'>536</span>  *     "alg": "RS256",
<span class='line'>537</span>  *     "typ": "JWS"
<span class='line'>538</span>  *   }',
<span class='line'>539</span>  *   payloadPP: 
<span class='line'>540</span>  *   '{
<span class='line'>541</span>  *     "product": "orange",
<span class='line'>542</span>  *     "quantity": 100
<span class='line'>543</span>  *   }',
<span class='line'>544</span>  *   sigHex: "91f3cd..." 
<span class='line'>545</span>  * }
<span class='line'>546</span>  */</span><span class="WHIT">
<span class='line'>547</span> </span><span class="NAME">KJUR.jws.JWS.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sJWS</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>548</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sJWS.split</span><span class="PUNC">(</span><span class="STRN">"."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uHeader</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">uPayload</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">uSig</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>551</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>552</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"malformed sJWS: wrong number of '.' splitted elements"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>553</span> 
<span class='line'>554</span> </span><span class="WHIT">    </span><span class="NAME">uHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>555</span> </span><span class="WHIT">    </span><span class="NAME">uPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>556</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">uSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT"> 
<span class='line'>557</span> 
<span class='line'>558</span>     </span><span class="NAME">result.headerObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.JWS.readSafeJSONString</span><span class="PUNC">(</span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">uHeader</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>559</span> </span><span class="WHIT">    </span><span class="NAME">result.payloadObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.JWS.readSafeJSONString</span><span class="PUNC">(</span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">uPayload</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>560</span> 
<span class='line'>561</span> </span><span class="WHIT">    </span><span class="NAME">result.headerPP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">JSON.stringify</span><span class="PUNC">(</span><span class="NAME">result.headerObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"  "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>562</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">result.payloadObj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>563</span> </span><span class="WHIT">	</span><span class="NAME">result.payloadPP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">uPayload</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>565</span> </span><span class="WHIT">	</span><span class="NAME">result.payloadPP</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">JSON.stringify</span><span class="PUNC">(</span><span class="NAME">result.payloadObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"  "</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>566</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>567</span> 
<span class='line'>568</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">uSig</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>569</span> </span><span class="WHIT">	</span><span class="NAME">result.sigHex</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">uSig</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>570</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>571</span> 
<span class='line'>572</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>573</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>574</span> 
<span class='line'>575</span> </span><span class="COMM">/**
<span class='line'>576</span>  * @name verifyJWT
<span class='line'>577</span>  * @memberOf KJUR.jws.JWS
<span class='line'>578</span>  * @function
<span class='line'>579</span>  * @static
<span class='line'>580</span>  * @param {String} sJWT string of JSON Web Token(JWT) to verify
<span class='line'>581</span>  * @param {Object} key string of public key, certificate or key object to verify
<span class='line'>582</span>  * @param {Array} acceptField associative array of acceptable fields (OPTION)
<span class='line'>583</span>  * @return {Boolean} true if the JWT token is valid otherwise false
<span class='line'>584</span>  * @since jws 3.2.3 jsrsasign 4.8.0
<span class='line'>585</span>  *
<span class='line'>586</span>  * @description
<span class='line'>587</span>  * This method verifies a
<span class='line'>588</span>  * &lt;a href="https://tools.ietf.org/html/rfc7519">RFC 7519&lt;/a> 
<span class='line'>589</span>  * JSON Web Token(JWT).
<span class='line'>590</span>  * It will verify following:
<span class='line'>591</span>  * &lt;ul>
<span class='line'>592</span>  * &lt;li>Header.alg
<span class='line'>593</span>  * &lt;ul>
<span class='line'>594</span>  * &lt;li>alg is specified in JWT header.&lt;/li>
<span class='line'>595</span>  * &lt;li>alg is included in acceptField.alg array. (MANDATORY)&lt;/li>
<span class='line'>596</span>  * &lt;li>alg is proper for key.&lt;/li>
<span class='line'>597</span>  * &lt;/ul>
<span class='line'>598</span>  * &lt;/li>
<span class='line'>599</span>  * &lt;li>Payload.iss (issuer) - Payload.iss is included in acceptField.iss array if specified. (OPTION)&lt;/li>
<span class='line'>600</span>  * &lt;li>Payload.sub (subject) - Payload.sub is included in acceptField.sub array if specified. (OPTION)&lt;/li>
<span class='line'>601</span>  * &lt;li>Payload.aud (audience) - Payload.aud is included in acceptField.aud array or 
<span class='line'>602</span>  *     the same as value if specified. (OPTION)&lt;/li>
<span class='line'>603</span>  * &lt;li>Time validity
<span class='line'>604</span>  * &lt;ul>
<span class='line'>605</span>  * &lt;li>
<span class='line'>606</span>  * If acceptField.verifyAt as number of UNIX origin time is specifed for validation time, 
<span class='line'>607</span>  * this method will verify at the time for it, otherwise current time will be used to verify.
<span class='line'>608</span>  * &lt;/li>
<span class='line'>609</span>  * &lt;li>
<span class='line'>610</span>  * Clock of JWT generator or verifier can be fast or slow. If these clocks are
<span class='line'>611</span>  * very different, JWT validation may fail. To avoid such case, 'jsrsasign' supports
<span class='line'>612</span>  * 'acceptField.gracePeriod' parameter which specifies acceptable time difference
<span class='line'>613</span>  * of those clocks in seconds. So if you want to accept slow or fast in 2 hours,
<span class='line'>614</span>  * you can specify &lt;code>acceptField.gracePeriod = 2 * 60 * 60;&lt;/code>.
<span class='line'>615</span>  * "gracePeriod" is zero by default.
<span class='line'>616</span>  * "gracePeriod" is supported since jsrsasign 5.0.12.
<span class='line'>617</span>  * &lt;/li>
<span class='line'>618</span>  * &lt;li>Payload.exp (expire) - Validation time is smaller than Payload.exp + gracePeriod.&lt;/li>
<span class='line'>619</span>  * &lt;li>Payload.nbf (not before) - Validation time is greater than Payload.nbf - gracePeriod.&lt;/li>
<span class='line'>620</span>  * &lt;li>Payload.iat (issued at) - Validation time is greater than Payload.iat - gracePeriod.&lt;/li>
<span class='line'>621</span>  * &lt;/ul>
<span class='line'>622</span>  * &lt;/li>
<span class='line'>623</span>  * &lt;li>Payload.jti (JWT id) - Payload.jti is included in acceptField.jti if specified. (OPTION)&lt;/li>
<span class='line'>624</span>  * &lt;li>JWS signature of JWS is valid for specified key.&lt;/li>
<span class='line'>625</span>  * &lt;/ul>
<span class='line'>626</span>  *
<span class='line'>627</span>  * &lt;h4>acceptField parameters&lt;/h4>
<span class='line'>628</span>  * Here is available acceptField argument parameters:
<span class='line'>629</span>  * &lt;ul>
<span class='line'>630</span>  * &lt;li>alg - array of acceptable signature algorithm names (ex. ["HS256", "HS384"])&lt;/li>
<span class='line'>631</span>  * &lt;li>iss - array of acceptable issuer names (ex. ['http://foo.com'])&lt;/li>
<span class='line'>632</span>  * &lt;li>sub - array of acceptable subject names (ex. ['mailto:john@foo.com'])&lt;/li>
<span class='line'>633</span>  * &lt;li>aud - array of acceptable audience name (ex. ['http://foo.com'])&lt;/li>
<span class='line'>634</span>  * &lt;li>jti - string of acceptable JWT ID (OPTION) (ex. 'id1234')&lt;/li>
<span class='line'>635</span>  * &lt;li>
<span class='line'>636</span>  * verifyAt - time to verify 'nbf', 'iat' and 'exp' in UNIX seconds 
<span class='line'>637</span>  * (OPTION) (ex. 1377663900).  
<span class='line'>638</span>  * If this is not specified, current time of verifier will be used. 
<span class='line'>639</span>  * {@link KJUR.jws.IntDate} may be useful to specify it.
<span class='line'>640</span>  * &lt;/li>
<span class='line'>641</span>  * &lt;li>gracePeriod - acceptable time difference between signer and verifier
<span class='line'>642</span>  * in seconds (ex. 3600). If this is not specified, zero will be used.&lt;/li>
<span class='line'>643</span>  * &lt;/ul>
<span class='line'>644</span>  *
<span class='line'>645</span>  * @example
<span class='line'>646</span>  * // simple validation for HS256
<span class='line'>647</span>  * isValid = KJUR.jws.JWS.verifyJWT("eyJhbG...", "616161", {alg: ["HS256"]}),
<span class='line'>648</span>  *
<span class='line'>649</span>  * // full validation for RS or PS
<span class='line'>650</span>  * pubkey = KEYUTIL.getKey('-----BEGIN CERT...');
<span class='line'>651</span>  * isValid = KJUR.jws.JWS.verifyJWT('eyJh...', pubkey, {
<span class='line'>652</span>  *   alg: ['RS256', 'RS512', 'PS256', 'PS512'],
<span class='line'>653</span>  *   iss: ['http://foo.com'],
<span class='line'>654</span>  *   sub: ['mailto:john@foo.com', 'mailto:alice@foo.com'],
<span class='line'>655</span>  *   verifyAt: KJUR.jws.IntDate.get('20150520235959Z'),
<span class='line'>656</span>  *   aud: ['http://foo.com'], // aud: 'http://foo.com' is fine too.
<span class='line'>657</span>  *   jti: 'id123456',
<span class='line'>658</span>  *   gracePeriod: 1 * 60 * 60 // accept 1 hour slow or fast
<span class='line'>659</span>  * });
<span class='line'>660</span>  */</span><span class="WHIT">
<span class='line'>661</span> </span><span class="NAME">KJUR.jws.JWS.verifyJWT</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sJWT</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">acceptField</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>662</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KJUR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>663</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_jws</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR.jws</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>664</span> </span><span class="WHIT">	</span><span class="NAME">_KJUR_jws_JWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws.JWS</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>665</span> </span><span class="WHIT">	</span><span class="NAME">_readSafeJSONString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.readSafeJSONString</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>666</span> </span><span class="WHIT">	</span><span class="NAME">_inArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.inArray</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>667</span> </span><span class="WHIT">	</span><span class="NAME">_includedArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.includedArray</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>668</span> 
<span class='line'>669</span> </span><span class="WHIT">    </span><span class="COMM">// 0. checking dot concatinatd Base64URL encoded string</span><span class="WHIT">
<span class='line'>670</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">isBase64URLDot</span><span class="PUNC">(</span><span class="NAME">sJWT</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>671</span> 
<span class='line'>672</span> </span><span class="WHIT">    </span><span class="COMM">// 1. parse JWT</span><span class="WHIT">
<span class='line'>673</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sJWT.split</span><span class="PUNC">(</span><span class="STRN">"."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>674</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>675</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>676</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>677</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">uSignatureInput</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">uHeader</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">uPayload</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>678</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hSig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">b64utohex</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>679</span> 
<span class='line'>680</span> </span><span class="WHIT">    </span><span class="COMM">// 2. parse JWS header</span><span class="WHIT">
<span class='line'>681</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pHeader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_readSafeJSONString</span><span class="PUNC">(</span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">uHeader</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>682</span> 
<span class='line'>683</span> </span><span class="WHIT">    </span><span class="COMM">// 3. parse JWS payload</span><span class="WHIT">
<span class='line'>684</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pPayload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_readSafeJSONString</span><span class="PUNC">(</span><span class="NAME">b64utoutf8</span><span class="PUNC">(</span><span class="NAME">uPayload</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>685</span> 
<span class='line'>686</span> </span><span class="WHIT">    </span><span class="COMM">// 4. algorithm ('alg' in header) check</span><span class="WHIT">
<span class='line'>687</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pHeader.alg</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">acceptField.alg</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>689</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"acceptField.alg shall be specified"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>690</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_inArray</span><span class="PUNC">(</span><span class="NAME">pHeader.alg</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">acceptField.alg</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>691</span> 
<span class='line'>692</span> </span><span class="WHIT">    </span><span class="COMM">// 5. issuer ('iss' in payload) check</span><span class="WHIT">
<span class='line'>693</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.iss</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">acceptField.iss</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>694</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_inArray</span><span class="PUNC">(</span><span class="NAME">pPayload.iss</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">acceptField.iss</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>695</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>696</span> 
<span class='line'>697</span> </span><span class="WHIT">    </span><span class="COMM">// 6. subject ('sub' in payload) check</span><span class="WHIT">
<span class='line'>698</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.sub</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">acceptField.sub</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>699</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_inArray</span><span class="PUNC">(</span><span class="NAME">pPayload.sub</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">acceptField.sub</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>700</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>701</span> 
<span class='line'>702</span> </span><span class="WHIT">    </span><span class="COMM">// 7. audience ('aud' in payload) check</span><span class="WHIT">
<span class='line'>703</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.aud</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">acceptField.aud</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>704</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">pPayload.aud</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>705</span> </span><span class="WHIT">	    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_inArray</span><span class="PUNC">(</span><span class="NAME">pPayload.aud</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">acceptField.aud</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>706</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>707</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">pPayload.aud</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>708</span> </span><span class="WHIT">	    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_includedArray</span><span class="PUNC">(</span><span class="NAME">pPayload.aud</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">acceptField.aud</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>709</span> </span><span class="WHIT">		</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>710</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>711</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>712</span> 
<span class='line'>713</span> </span><span class="WHIT">    </span><span class="COMM">// 8. time validity </span><span class="WHIT">
<span class='line'>714</span> </span><span class="WHIT">    </span><span class="COMM">//   (nbf - gracePeriod &lt; now &lt; exp + gracePeriod) && (iat - gracePeriod &lt; now)</span><span class="WHIT">
<span class='line'>715</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">now</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws.IntDate.getNow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>716</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">acceptField.verifyAt</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">acceptField.verifyAt</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>717</span> </span><span class="WHIT">	</span><span class="NAME">now</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">acceptField.verifyAt</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>718</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>719</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">acceptField.gracePeriod</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='line'>720</span>         </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">acceptField.gracePeriod</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT">	</span><span class="NAME">acceptField.gracePeriod</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>723</span> 
<span class='line'>724</span> </span><span class="WHIT">    </span><span class="COMM">// 8.1 expired time 'exp' check</span><span class="WHIT">
<span class='line'>725</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.exp</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">pPayload.exp</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>726</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.exp</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">acceptField.gracePeriod</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">now</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>727</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>728</span> 
<span class='line'>729</span> </span><span class="WHIT">    </span><span class="COMM">// 8.2 not before time 'nbf' check</span><span class="WHIT">
<span class='line'>730</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.nbf</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">pPayload.nbf</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>731</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">now</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">pPayload.nbf</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">acceptField.gracePeriod</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>732</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>733</span> </span><span class="WHIT">    
<span class='line'>734</span>     </span><span class="COMM">// 8.3 issued at time 'iat' check</span><span class="WHIT">
<span class='line'>735</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.iat</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">pPayload.iat</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>736</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">now</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">pPayload.iat</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">acceptField.gracePeriod</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>737</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>738</span> 
<span class='line'>739</span> </span><span class="WHIT">    </span><span class="COMM">// 9 JWT id 'jti' check</span><span class="WHIT">
<span class='line'>740</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.jti</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">acceptField.jti</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>741</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pPayload.jti</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">acceptField.jti</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>742</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>743</span> 
<span class='line'>744</span> </span><span class="WHIT">    </span><span class="COMM">// 10 JWS signature check</span><span class="WHIT">
<span class='line'>745</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_JWS.verify</span><span class="PUNC">(</span><span class="NAME">sJWT</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">acceptField.alg</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>746</span> 
<span class='line'>747</span> </span><span class="WHIT">    </span><span class="COMM">// 11 passed all check</span><span class="WHIT">
<span class='line'>748</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>749</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>750</span> 
<span class='line'>751</span> </span><span class="COMM">/**
<span class='line'>752</span>  * check whether array is included by another array
<span class='line'>753</span>  * @name includedArray
<span class='line'>754</span>  * @memberOf KJUR.jws.JWS
<span class='line'>755</span>  * @function
<span class='line'>756</span>  * @static
<span class='line'>757</span>  * @param {Array} a1 check whether set a1 is included by a2
<span class='line'>758</span>  * @param {Array} a2 check whether set a1 is included by a2
<span class='line'>759</span>  * @return {Boolean} check whether set a1 is included by a2
<span class='line'>760</span>  * @since jws 3.2.3
<span class='line'>761</span>  * This method verifies whether an array is included by another array.
<span class='line'>762</span>  * It doesn't care about item ordering in a array.
<span class='line'>763</span>  * @example
<span class='line'>764</span>  * KJUR.jws.JWS.includedArray(['b'], ['b', 'c', 'a']) => true
<span class='line'>765</span>  * KJUR.jws.JWS.includedArray(['a', 'b'], ['b', 'c', 'a']) => true
<span class='line'>766</span>  * KJUR.jws.JWS.includedArray(['a', 'b'], ['b', 'c']) => false
<span class='line'>767</span>  */</span><span class="WHIT">
<span class='line'>768</span> </span><span class="NAME">KJUR.jws.JWS.includedArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">a1</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_inArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.JWS.inArray</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a1</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a1</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a1.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>773</span> 
<span class='line'>774</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a1.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="WHIT"> </span><span class="NAME">_inArray</span><span class="PUNC">(</span><span class="NAME">a1</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a2</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>778</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>779</span> 
<span class='line'>780</span> </span><span class="COMM">/**
<span class='line'>781</span>  * check whether item is included by array
<span class='line'>782</span>  * @name inArray
<span class='line'>783</span>  * @memberOf KJUR.jws.JWS
<span class='line'>784</span>  * @function
<span class='line'>785</span>  * @static
<span class='line'>786</span>  * @param {String} item check whether item is included by array
<span class='line'>787</span>  * @param {Array} a check whether item is included by array
<span class='line'>788</span>  * @return {Boolean} check whether item is included by array
<span class='line'>789</span>  * @since jws 3.2.3
<span class='line'>790</span>  * This method verifies whether an item is included by an array.
<span class='line'>791</span>  * It doesn't care about item ordering in an array.
<span class='line'>792</span>  * @example
<span class='line'>793</span>  * KJUR.jws.JWS.inArray('b', ['b', 'c', 'a']) => true
<span class='line'>794</span>  * KJUR.jws.JWS.inArray('a', ['b', 'c', 'a']) => true
<span class='line'>795</span>  * KJUR.jws.JWS.inArray('a', ['b', 'c']) => false
<span class='line'>796</span>  */</span><span class="WHIT">
<span class='line'>797</span> </span><span class="NAME">KJUR.jws.JWS.inArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>798</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>799</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>800</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"number"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>801</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>802</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>803</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>804</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>805</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>806</span> 
<span class='line'>807</span> </span><span class="COMM">/**
<span class='line'>808</span>  * static associative array of general signature algorithm name from JWS algorithm name
<span class='line'>809</span>  * @since jws 3.0.0
<span class='line'>810</span>  */</span><span class="WHIT">
<span class='line'>811</span> </span><span class="NAME">KJUR.jws.JWS.jwsalg2sigalg</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT">    </span><span class="STRN">"HS256"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"HmacSHA256"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>813</span> </span><span class="WHIT">    </span><span class="STRN">"HS384"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"HmacSHA384"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>814</span> </span><span class="WHIT">    </span><span class="STRN">"HS512"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"HmacSHA512"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT">    </span><span class="STRN">"RS256"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA256withRSA"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>816</span> </span><span class="WHIT">    </span><span class="STRN">"RS384"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA384withRSA"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>817</span> </span><span class="WHIT">    </span><span class="STRN">"RS512"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA512withRSA"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>818</span> </span><span class="WHIT">    </span><span class="STRN">"ES256"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA256withECDSA"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT">    </span><span class="STRN">"ES384"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA384withECDSA"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT">    </span><span class="STRN">"ES512"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA512withECDSA"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT">    </span><span class="STRN">"PS256"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA256withRSAandMGF1"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>822</span> </span><span class="WHIT">    </span><span class="STRN">"PS384"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA384withRSAandMGF1"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>823</span> </span><span class="WHIT">    </span><span class="STRN">"PS512"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"SHA512withRSAandMGF1"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>824</span> </span><span class="WHIT">    </span><span class="STRN">"none"</span><span class="PUNC">:</span><span class="WHIT">	</span><span class="STRN">"none"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>825</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>826</span> 
<span class='line'>827</span> </span><span class="COMM">// === utility static method ==================================================</span><span class="WHIT">
<span class='line'>828</span> 
<span class='line'>829</span> </span><span class="COMM">/**
<span class='line'>830</span>  * check whether a String "s" is a safe JSON string or not.&lt;br/>
<span class='line'>831</span>  * If a String "s" is a malformed JSON string or an other object type
<span class='line'>832</span>  * this returns 0, otherwise this returns 1.
<span class='line'>833</span>  * @name isSafeJSONString
<span class='line'>834</span>  * @memberOf KJUR.jws.JWS
<span class='line'>835</span>  * @function
<span class='line'>836</span>  * @static
<span class='line'>837</span>  * @param {String} s JSON string
<span class='line'>838</span>  * @return {Number} 1 or 0
<span class='line'>839</span>  */</span><span class="WHIT">
<span class='line'>840</span> </span><span class="NAME">KJUR.jws.JWS.isSafeJSONString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>841</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>842</span> </span><span class="WHIT">    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>843</span> </span><span class="WHIT">	</span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jsonParse</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>844</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>845</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o.constructor</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>846</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">h</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">h</span><span class="PUNC">[</span><span class="NAME">p</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>847</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>848</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>849</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>850</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>851</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>852</span> 
<span class='line'>853</span> </span><span class="COMM">/**
<span class='line'>854</span>  * read a String "s" as JSON object if it is safe.&lt;br/>
<span class='line'>855</span>  * If a String "s" is a malformed JSON string or not JSON string,
<span class='line'>856</span>  * this returns null, otherwise returns JSON object.
<span class='line'>857</span>  * @name readSafeJSONString
<span class='line'>858</span>  * @memberOf KJUR.jws.JWS
<span class='line'>859</span>  * @function
<span class='line'>860</span>  * @static
<span class='line'>861</span>  * @param {String} s JSON string
<span class='line'>862</span>  * @return {Object} JSON object or null
<span class='line'>863</span>  * @since 1.1.1
<span class='line'>864</span>  */</span><span class="WHIT">
<span class='line'>865</span> </span><span class="NAME">KJUR.jws.JWS.readSafeJSONString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>866</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>867</span> </span><span class="WHIT">    </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>868</span> </span><span class="WHIT">	</span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">jsonParse</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>869</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"object"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>870</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o.constructor</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>871</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>872</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ex</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>873</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>874</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>875</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>876</span> 
<span class='line'>877</span> </span><span class="COMM">/**
<span class='line'>878</span>  * get Encoed Signature Value from JWS string.&lt;br/>
<span class='line'>879</span>  * @name getEncodedSignatureValueFromJWS
<span class='line'>880</span>  * @memberOf KJUR.jws.JWS
<span class='line'>881</span>  * @function
<span class='line'>882</span>  * @static
<span class='line'>883</span>  * @param {String} sJWS JWS signature string to be verified
<span class='line'>884</span>  * @return {String} string of Encoded Signature Value 
<span class='line'>885</span>  * @throws if sJWS is not comma separated string such like "Header.Payload.Signature".
<span class='line'>886</span>  */</span><span class="WHIT">
<span class='line'>887</span> </span><span class="NAME">KJUR.jws.JWS.getEncodedSignatureValueFromJWS</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">sJWS</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>888</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">matchResult</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sJWS.match</span><span class="PUNC">(</span><span class="REGX">/^[^.]+\.[^.]+\.([^.]+)$/</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>889</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">matchResult</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>890</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"JWS signature is not a form of 'Head.Payload.SigValue'."</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>891</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>892</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">matchResult</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>893</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>894</span> 
<span class='line'>895</span> </span><span class="COMM">/**
<span class='line'>896</span>  * get RFC 7638 JWK thumbprint from JWK object
<span class='line'>897</span>  * @name getJWKthumbprint
<span class='line'>898</span>  * @memberOf KJUR.jws.JWS
<span class='line'>899</span>  * @function
<span class='line'>900</span>  * @static
<span class='line'>901</span>  * @param {Object} o JWK object to be calculated thumbprint
<span class='line'>902</span>  * @return {String} Base64 URL encoded JWK thumbprint value
<span class='line'>903</span>  * @since jsrsasign 5.0.2 jws 3.3.2
<span class='line'>904</span>  * @description
<span class='line'>905</span>  * This method calculates JWK thmubprint for specified JWK object
<span class='line'>906</span>  * as described in 
<span class='line'>907</span>  * &lt;a href="https://tools.ietf.org/html/rfc7638">RFC 7638&lt;/a>.
<span class='line'>908</span>  * It supports all type of "kty". (i.e. "RSA", "EC" and "oct"
<span class='line'>909</span>  * (for symmetric key))
<span class='line'>910</span>  * Working sample is 
<span class='line'>911</span>  * &lt;a href="https://kjur.github.io/jsrsasign/sample/tool_jwktp.html">here&lt;/a>.
<span class='line'>912</span>  * @example
<span class='line'>913</span>  * jwk = {"kty":"RSA", "n":"0vx...", "e":"AQAB", ...};
<span class='line'>914</span>  * thumbprint = KJUR.jws.JWS.getJWKthumbprint(jwk);
<span class='line'>915</span>  */</span><span class="WHIT">
<span class='line'>916</span> </span><span class="NAME">KJUR.jws.JWS.getJWKthumbprint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>917</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"RSA"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>918</span> </span><span class="WHIT">	</span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"EC"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>919</span> </span><span class="WHIT">	</span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"oct"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>920</span> </span><span class="WHIT">	</span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"unsupported algorithm for JWK Thumprint"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>921</span> 
<span class='line'>922</span> </span><span class="WHIT">    </span><span class="COMM">// 1. get canonically ordered json string</span><span class="WHIT">
<span class='line'>923</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'{'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>924</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"RSA"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>925</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o.n</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o.e</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>926</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"wrong n and e value for RSA key"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>927</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'e'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.e</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'",'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>928</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'kty'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'",'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>929</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'n'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.n</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"}'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>930</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"EC"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>931</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o.crv</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> 
<span class='line'>932</span> 	    </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o.x</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>933</span> </span><span class="WHIT">	    </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o.y</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>934</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"wrong crv, x and y value for EC key"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>935</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'crv'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.crv</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'",'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>936</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'kty'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'",'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>937</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'x'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'",'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>938</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'y'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.y</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"}'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>939</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"oct"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>940</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">o.k</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>941</span> </span><span class="WHIT">	    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"wrong k value for oct(symmetric) key"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>942</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'kty'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.kty</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'",'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>943</span> </span><span class="WHIT">	</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'k'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'":"'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">o.k</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"}'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>944</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>945</span> </span><span class="WHIT">    </span><span class="COMM">//alert(s);</span><span class="WHIT">
<span class='line'>946</span> 
<span class='line'>947</span> </span><span class="WHIT">    </span><span class="COMM">// 2. get thumb print</span><span class="WHIT">
<span class='line'>948</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hJWK</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rstrtohex</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>949</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hash</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.crypto.Util.hashHex</span><span class="PUNC">(</span><span class="NAME">hJWK</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"sha256"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>950</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">hashB64U</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">hextob64u</span><span class="PUNC">(</span><span class="NAME">hash</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>951</span> 
<span class='line'>952</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">hashB64U</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>953</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>954</span> 
<span class='line'>955</span> </span><span class="COMM">/**
<span class='line'>956</span>  * IntDate class for time representation for JSON Web Token(JWT)
<span class='line'>957</span>  * @class KJUR.jws.IntDate class
<span class='line'>958</span>  * @name KJUR.jws.IntDate
<span class='line'>959</span>  * @since jws 3.0.1
<span class='line'>960</span>  * @description
<span class='line'>961</span>  * Utility class for IntDate which is integer representation of UNIX origin time
<span class='line'>962</span>  * used in JSON Web Token(JWT).
<span class='line'>963</span>  */</span><span class="WHIT">
<span class='line'>964</span> </span><span class="NAME">KJUR.jws.IntDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>965</span> 
<span class='line'>966</span> </span><span class="COMM">/**
<span class='line'>967</span>  * get UNIX origin time from by string
<span class='line'>968</span>  * @name get
<span class='line'>969</span>  * @memberOf KJUR.jws.IntDate
<span class='line'>970</span>  * @function
<span class='line'>971</span>  * @static
<span class='line'>972</span>  * @param {String} s string of time representation
<span class='line'>973</span>  * @return {Integer} UNIX origin time in seconds for argument 's'
<span class='line'>974</span>  * @since jws 3.0.1
<span class='line'>975</span>  * @throws "unsupported format: s" when malformed format
<span class='line'>976</span>  * @description
<span class='line'>977</span>  * This method will accept following representation of time.
<span class='line'>978</span>  * &lt;ul>
<span class='line'>979</span>  * &lt;li>now - current time&lt;/li>
<span class='line'>980</span>  * &lt;li>now + 1hour - after 1 hour from now&lt;/li>
<span class='line'>981</span>  * &lt;li>now + 1day - after 1 day from now&lt;/li>
<span class='line'>982</span>  * &lt;li>now + 1month - after 30 days from now&lt;/li>
<span class='line'>983</span>  * &lt;li>now + 1year - after 365 days from now&lt;/li>
<span class='line'>984</span>  * &lt;li>YYYYmmDDHHMMSSZ - UTC time (ex. 20130828235959Z)&lt;/li>
<span class='line'>985</span>  * &lt;li>number - UNIX origin time (seconds from 1970-01-01 00:00:00) (ex. 1377714748)&lt;/li>
<span class='line'>986</span>  * &lt;/ul>
<span class='line'>987</span>  */</span><span class="WHIT">
<span class='line'>988</span> </span><span class="NAME">KJUR.jws.IntDate.get</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>989</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_IntDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">KJUR.jws.IntDate</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>990</span> </span><span class="WHIT">	</span><span class="NAME">_getNow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_IntDate.getNow</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>991</span> </span><span class="WHIT">	</span><span class="NAME">_getZulu</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">_KJUR_jws_IntDate.getZulu</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>992</span> 
<span class='line'>993</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"now"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>994</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_getNow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>995</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"now + 1hour"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>996</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_getNow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>997</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"now + 1day"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>998</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_getNow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">24</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>999</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"now + 1month"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1000</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_getNow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">24</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">30</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1001</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">"now + 1year"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1002</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_getNow</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">24</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">365</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1003</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/Z$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">_getZulu</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">s.match</span><span class="PUNC">(</span><span class="REGX">/^[0-9]+$/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1006</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">parseInt</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1007</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1008</span> </span><span class="WHIT">    </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="STRN">"unsupported format: "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">s</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1009</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1010</span> 
<span class='line'>1011</span> </span><span class="COMM">/**
<span class='line'>1012</span>  * get UNIX origin time from Zulu time representation string
<span class='line'>1013</span>  * @name getZulu
<span class='line'>1014</span>  * @memberOf KJUR.jws.IntDate
<span class='line'>1015</span>  * @function
<span class='line'>1016</span>  * @static
<span class='line'>1017</span>  * @param {String} s string of Zulu time representation (ex. 20151012125959Z)
<span class='line'>1018</span>  * @return {Integer} UNIX origin time in seconds for argument 's'
<span class='line'>1019</span>  * @since jws 3.0.1
<span class='line'>1020</span>  * @throws "unsupported format: s" when malformed format
<span class='line'>1021</span>  * @description
<span class='line'>1022</span>  * This method provides UNIX origin time from Zulu time.
<span class='line'>1023</span>  * Following representations are supported:
<span class='line'>1024</span>  * &lt;ul>
<span class='line'>1025</span>  * &lt;li>YYYYMMDDHHmmSSZ - GeneralizedTime format&lt;/li>
<span class='line'>1026</span>  * &lt;li>YYMMDDHHmmSSZ - UTCTime format. If YY is greater or equal to 
<span class='line'>1027</span>  * 50 then it represents 19YY otherwise 20YY.&lt;/li>
<span class='line'>1028</span>  * &lt;/ul>
<span class='line'>1029</span>  * @example
<span class='line'>1030</span>  * KJUR.jws.IntDate.getZulu("20151012125959Z") => 1478...
<span class='line'>1031</span>  * KJUR.jws.IntDate.getZulu("151012125959Z") => 1478...
<span class='line'>1032</span>  */</span><span class="WHIT">
<span class='line'>1033</span> </span><span class="NAME">KJUR.jws.IntDate.getZulu</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1034</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">zulutosec</span><span class="PUNC">(</span><span class="NAME">s</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1035</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1036</span> 
<span class='line'>1037</span> </span><span class="COMM">/**
<span class='line'>1038</span>  * get UNIX origin time of current time
<span class='line'>1039</span>  * @name getNow
<span class='line'>1040</span>  * @memberOf KJUR.jws.IntDate
<span class='line'>1041</span>  * @function
<span class='line'>1042</span>  * @static
<span class='line'>1043</span>  * @return {Integer} UNIX origin time for current time
<span class='line'>1044</span>  * @since jws 3.0.1
<span class='line'>1045</span>  * @description
<span class='line'>1046</span>  * This method provides UNIX origin time for current time
<span class='line'>1047</span>  * @example
<span class='line'>1048</span>  * KJUR.jws.IntDate.getNow() => 1478...
<span class='line'>1049</span>  */</span><span class="WHIT">
<span class='line'>1050</span> </span><span class="NAME">KJUR.jws.IntDate.getNow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1051</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">~</span><span class="PUNC">~</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">/</span><span class="WHIT"> </span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1052</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1053</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1054</span> 
<span class='line'>1055</span> </span><span class="COMM">/**
<span class='line'>1056</span>  * get UTC time string from UNIX origin time value
<span class='line'>1057</span>  * @name intDate2UTCString
<span class='line'>1058</span>  * @memberOf KJUR.jws.IntDate
<span class='line'>1059</span>  * @function
<span class='line'>1060</span>  * @static
<span class='line'>1061</span>  * @param {Integer} intDate UNIX origin time value (ex. 1478...)
<span class='line'>1062</span>  * @return {String} UTC time string
<span class='line'>1063</span>  * @since jws 3.0.1
<span class='line'>1064</span>  * @description
<span class='line'>1065</span>  * This method provides UTC time string for UNIX origin time value.
<span class='line'>1066</span>  * @example
<span class='line'>1067</span>  * KJUR.jws.IntDate.intDate2UTCString(1478...) => "2015 Oct ..."
<span class='line'>1068</span>  */</span><span class="WHIT">
<span class='line'>1069</span> </span><span class="NAME">KJUR.jws.IntDate.intDate2UTCString</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">intDate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1070</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">intDate</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1071</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">d.toUTCString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1072</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1073</span> 
<span class='line'>1074</span> </span><span class="COMM">/**
<span class='line'>1075</span>  * get UTC time string from UNIX origin time value
<span class='line'>1076</span>  * @name intDate2Zulu
<span class='line'>1077</span>  * @memberOf KJUR.jws.IntDate
<span class='line'>1078</span>  * @function
<span class='line'>1079</span>  * @static
<span class='line'>1080</span>  * @param {Integer} intDate UNIX origin time value (ex. 1478...)
<span class='line'>1081</span>  * @return {String} Zulu time string
<span class='line'>1082</span>  * @since jws 3.0.1
<span class='line'>1083</span>  * @description
<span class='line'>1084</span>  * This method provides Zulu time string for UNIX origin time value.
<span class='line'>1085</span>  * @example
<span class='line'>1086</span>  * KJUR.jws.IntDate.intDate2UTCString(1478...) => "20151012...Z"
<span class='line'>1087</span>  */</span><span class="WHIT">
<span class='line'>1088</span> </span><span class="NAME">KJUR.jws.IntDate.intDate2Zulu</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">intDate</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1089</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">intDate</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">1000</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1090</span> </span><span class="WHIT">	</span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"0000"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCFullYear</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">4</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1091</span> </span><span class="WHIT">	</span><span class="NAME">mon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">d.getUTCMonth</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1092</span> </span><span class="WHIT">	</span><span class="NAME">day</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCDate</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1093</span> </span><span class="WHIT">	</span><span class="NAME">hour</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCHours</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1094</span> </span><span class="WHIT">	</span><span class="NAME">min</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCMinutes</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1095</span> </span><span class="WHIT">        </span><span class="NAME">sec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">  </span><span class="PUNC">(</span><span class="STRN">"00"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">d.getUTCSeconds</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">slice</span><span class="PUNC">(</span><span class="PUNC">-</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1096</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">year</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">mon</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">day</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">hour</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">min</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">sec</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"Z"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1097</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1098</span> 
<span class='line'>1099</span> </span></pre></body></html>